#!/bin/bash
cd /tmp
# 关闭特效模式以节省性能
sed -i "s%\[Compositing\]%\[Compositing\]\nEnabled=true%g" ~/.config/deepin-kwinrc
sed -i "s%\[Compositing\]%\[Compositing\]\nOpenGLIsUnsafe=true%g" ~/.config/deepin-kwinrc
sed -i "s%OpenGLIsUnsafe=false%OpenGLIsUnsafe=true%g" ~/.config/deepin-kwinrc
killall deepin-kwin_x11 -9
sleep 1
debianVersion=`cat /etc/debian_version`
if [[ $debianVersion==12.* ]]; then
	cd /tmp
	killall gxde-dock dde-osd -9
	nohup gxde-dock &
fi

## Kwin Blur效果会爆炸，所以需要让这两个家伙重新启动下
killall gxde-launcher gxde-dock
#nohup gxde-launcher &
nohup gxde-control-center &


## 预加载dlauncher加速启动


# 加载 VNC（如果开启的话）
if [[ -f ~/.config/GXDE/gxde-x11vnc ]]; then
	if [[ -f ~/.vnc/passwd ]]; then
		nohup x11vnc --forever -rfbauth ~/.vnc/passwd -capslock &
	else
		nohup x11vnc --forever -capslock &  # 免密
	fi
fi

# 安装 deb
if [[ -e /run/live/medium/gxde-deb ]]; then
	sudo env DEBIAN_FRONTEND=noninteractive dpkg -i /run/live/medium/gxde-deb/*.deb 
fi
if [[ -e /run/live/medium/live/config.squashfs ]]; then
	sudo mkdir -pv /tmp/gxde-desktop-base-live-installer
	sudo mount /run/live/medium/live/config.squashfs /tmp/gxde-desktop-base-live-installer
	sudo env DEBIAN_FRONTEND=noninteractive dpkg -i /tmp/gxde-desktop-base-live-installer/*
fi
